function [ERRZ] = computerEssentialErrorSVDNFramesGeneralMODREWEIGHTED(x,F,weights,w,h,outputformat)

[K]=convertXTOKselfK(x,w,h);
KT=K';

n=size(F,2);

ERRZ=zeros(n,1);



for i=1:n
   T(i,1) = computerEssentialErrorSVD(F{1,i},K,KT);
end

%T
T=T.^2;

%sigma = 1; % 1.253*mad(T,0); %std( T) ;
sigma=1.4826*mad(T,1);
N=abs(bisquare(T/sigma));

T=T.*N;
ERRZ=sum(T);

end

function w = bisquare(r)
t= 4.685;
r=r/t;
w = (abs(r)<1) .* (1 - (r/1).^2).^2;
w(r<eps,1)=0;
end

function w = andrews(r)
t = 1.339;
r=r/t;
r = max(sqrt(eps(class(r))), abs(r));
w = (abs(r)<pi) .* sin(r) ./ r;
end


function w = cauchy(r)
t= 2.385;
r=r/t;
w = 1 ./ (1 + r.^2);
end
